import VueRouter from "vue-router";
import Vue from "vue";
import allRoutes from "./allRouter";

Vue.use(VueRouter);

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const routes = [
  {
    path: "/login",
    component: () => import("pages/login"),
    name: "login",
  },
  {
    path: "/",
    redirect: "/welcome",
    component: () => import("pages/home"),
    name: "home",
    children: allRoutes,
  },
  {
    path: "*",
    component: () => import("pages/404"),
    name: "404",
  }
];

const router = new VueRouter({
  routes,
});

export default router;
